<?php
/**
 * Permission Service
 * User: zng
 * Date: 2019/11/4
 * Time: 14:34
 */
namespace app\api\service\system;

use app\api\model\system\System as SystemModels;

Class System {

    /**
     * 获取system设置
     *
     * @return int
     */
    public function systemSet(string $key)
    {
        return SystemModels::where('key', $key)->value('value');
    }

    /**
     * 查询当前店家是否营业
     *
     * @return bool
     */
    public function rest()
    {
        $times = $this->systemSet('bookable_time');
        if ( ! $times ) {
            return true;
        }
        $timeArr = explode('|', $times);
        $current_time = strtotime(date("H:i", time()));
        return strtotime($timeArr[0]) < $current_time && strtotime($timeArr[1]) > $current_time;
    }

}